using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Member_RecordChash : Member, IRequiresSessionState
{
	protected HtmlSelect PaymentType;
	protected HtmlSelect Stuate;
	protected HtmlInputText Sn;
	protected Button submit;
	protected Repeater Repeater1;
	protected LinkButton btnFirst;
	protected LinkButton btnBack;
	protected LinkButton btnNext;
	protected LinkButton btnLast;
	protected HtmlTableRow trPage;
	protected HtmlTable noread;
	private ToCashBLL _ToCashBLL = null;
	private DataTable dt1 = null;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected ToCashBLL to_ToCashBLL
	{
		get
		{
			ToCashBLL toCashBLL;
			if (this._ToCashBLL == null)
			{
				this._ToCashBLL = new ToCashBLL(this.conn);
				toCashBLL = this._ToCashBLL;
			}
			else
			{
				toCashBLL = this._ToCashBLL;
			}
			return toCashBLL;
		}
	}
	public int PageIndex
	{
		get
		{
			return (int)this.ViewState["PageIndex"];
		}
		set
		{
			this.ViewState["PageIndex"] = value;
		}
	}
	public int PageSize
	{
		get
		{
			return (int)this.ViewState["PageSize"];
		}
		set
		{
			this.ViewState["PageSize"] = value;
		}
	}
	public int PageCount
	{
		get
		{
			return (int)this.ViewState["PageCount"];
		}
		set
		{
			this.ViewState["PageCount"] = value;
		}
	}
	public int Stamp
	{
		get
		{
			return (int)this.ViewState["Stamp"];
		}
		set
		{
			this.ViewState["Stamp"] = value;
		}
	}
	public int RecordCount
	{
		get;
		set;
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.PageIndex = 1;
			this.ViewState["PageSize"] = 6;
			this.Stamp = 1;
			this.dt1 = this.to_ToCashBLL.GetToChashByUserID(this.PageIndex, this.PageSize, base.user.UserID);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
	}
	public void ShowData(int pageIndex, DataTable dt, Repeater rpter)
	{
		if (this.Stamp == 1)
		{
			this.RecordCount = this._ToCashBLL.GetToChashByUserIDCount(base.user.UserID).Rows.Count;
		}
		else
		{
			this.RecordCount = this.to_ToCashBLL.GetToChashByByUserIdSearchCount(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, base.user.UserID).Rows.Count;
		}
		this.PageCount = ((this.RecordCount % this.PageSize == 0) ? (this.RecordCount / this.PageSize) : (this.RecordCount / this.PageSize + 1));
		if (this.PageIndex == 1)
		{
			this.btnFirst.Enabled = false;
			this.btnBack.Enabled = false;
			this.btnNext.Enabled = true;
			this.btnLast.Enabled = true;
		}
		else
		{
			if (this.PageIndex >= this.PageCount)
			{
				this.PageIndex = this.PageCount;
				this.btnFirst.Enabled = true;
				this.btnBack.Enabled = true;
				this.btnNext.Enabled = false;
				this.btnLast.Enabled = false;
			}
			else
			{
				this.btnFirst.Enabled = true;
				this.btnBack.Enabled = true;
				this.btnNext.Enabled = true;
				this.btnLast.Enabled = true;
			}
		}
		if (this.PageCount == 0 || this.RecordCount <= this.PageSize)
		{
			this.btnFirst.Enabled = false;
			this.btnBack.Enabled = false;
			this.btnNext.Enabled = false;
			this.btnLast.Enabled = false;
		}
		if (dt.Rows.Count != 0)
		{
			rpter.DataSource = dt;
			this.noread.Visible = false;
		}
		else
		{
			this.trPage.Visible = false;
			this.noread.Visible = true;
		}
		rpter.DataBind();
		foreach (RepeaterItem repeaterItem in this.Repeater1.Items)
		{
			Label label = (Label)repeaterItem.FindControl("lblTCStuate");
			LinkButton linkButton = (LinkButton)repeaterItem.FindControl("linkDelete");
			HyperLink hyperLink = (HyperLink)repeaterItem.FindControl("linkDesc");
			if (label.Text == "1")
			{
				label.Text = "等待审核";
				linkButton.Visible = false;
				hyperLink.Visible = true;
			}
			else
			{
				if (label.Text == "2")
				{
					label.Text = "已审核";
					linkButton.Visible = false;
					hyperLink.Visible = true;
				}
				else
				{
					if (label.Text == "3")
					{
						label.Text = "已关闭";
						linkButton.Visible = true;
						hyperLink.Visible = true;
					}
				}
			}
		}
	}
	protected void btnFirst_Click(object sender, EventArgs e)
	{
		this.PageIndex = 1;
		if (this.Stamp == 1)
		{
			this.dt1 = this.to_ToCashBLL.GetToChashByUserID(this.PageIndex, this.PageSize, base.user.UserID);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.to_ToCashBLL.GetToChashByByUserIdSearch(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, this.PageIndex, this.PageSize, base.user.UserID);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnBack_Click(object sender, EventArgs e)
	{
		this.PageIndex--;
		if (this.Stamp == 1)
		{
			this.dt1 = this.to_ToCashBLL.GetToChashByUserID(this.PageIndex, this.PageSize, base.user.UserID);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.to_ToCashBLL.GetToChashByByUserIdSearch(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, this.PageIndex, this.PageSize, base.user.UserID);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnNext_Click(object sender, EventArgs e)
	{
		this.PageIndex++;
		if (this.Stamp == 1)
		{
			this.dt1 = this.to_ToCashBLL.GetToChashByUserID(this.PageIndex, this.PageSize, base.user.UserID);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.to_ToCashBLL.GetToChashByByUserIdSearch(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, this.PageIndex, this.PageSize, base.user.UserID);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnLast_Click(object sender, EventArgs e)
	{
		this.PageIndex = this.PageCount;
		if (this.Stamp == 1)
		{
			this.dt1 = this.to_ToCashBLL.GetToChashByUserID(this.PageIndex, this.PageSize, base.user.UserID);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.to_ToCashBLL.GetToChashByByUserIdSearch(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, this.PageIndex, this.PageSize, base.user.UserID);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void submit_Click(object sender, EventArgs e)
	{
		this.Stamp = 2;
		this.dt1 = this.to_ToCashBLL.GetToChashByByUserIdSearch(this.PaymentType.Value, this.Stuate.Value, this.Sn.Value, this.PageIndex, this.PageSize, base.user.UserID);
		this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
	}
	protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
	{
		if (e.CommandName == "del")
		{
			bool deletToChashByToChashId = this.to_ToCashBLL.GetDeletToChashByToChashId(e.CommandArgument.ToString(), base.user.UserID);
			if (deletToChashByToChashId)
			{
				this.WriteSuccessMsg("", Language.GetAdminMsg("Common/DeleteSuccess"), "RecordChash.aspx");
			}
		}
	}
	protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
	{
		foreach (RepeaterItem repeaterItem in this.Repeater1.Items)
		{
			LinkButton linkButton = (LinkButton)repeaterItem.FindControl("linkDelete");
			linkButton.Attributes.Add("onclick", "return confirm('确定要删除吗?')");
		}
	}
}
